﻿using System.Windows;
using System.Windows.Input;
using MDCAdminTool.Reports;

namespace MDCAdminTool.Commands
{
    public class CacheNameSizesByHost : AddCartTabCommandBinding
    {
        public CacheNameSizesByHost()
        {
            Command    = Application.Current.Resources["CacheNameSizesByHost"] as ICommand;
        }

        protected override void OnCanExecute( object sender , CanExecuteRoutedEventArgs e )
        {
            e.CanExecute = true;
        }
        protected override void OnExecuted( object sender , ExecutedRoutedEventArgs e )
        {
            var cache = e.Parameter as CacheHost;
            if ( cache != null )
            {
                foreach ( var c in cache.Cluster.Hosts )
                {
                    c.LoadStatistics();
                }

                AddNewTab( 
                    "CacheName Sizes By Host" , 
                    typeof(CacheNameSizesByHostChart) , 
                    cache );
            }
        }
    }
}